﻿Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace System.Workflow.ComponentModel.Design
    Public Class ConnectorAccessibleObject
        Inherits AccessibleObject
        ' Methods
        Public Sub New(ByVal connector As Connector)
            If (connector Is Nothing) Then
                Throw New ArgumentNullException("connector")
            End If
            Me.connector = connector
        End Sub

        Public Overrides Function HitTest(ByVal x As Integer, ByVal y As Integer) As AccessibleObject
            Dim parentView As WorkflowView = Me.connector.ParentDesigner.ParentView
            If Me.connector.HitTest(parentView.ScreenPointToLogical(New Point(x, y))) Then
                Return Me
            End If
            Return Nothing
        End Function


        ' Properties
        Public Overrides ReadOnly Property Bounds As Rectangle
            Get
                Dim parentView As WorkflowView = Me.connector.ParentDesigner.ParentView
                Dim bounds As Rectangle = Me.connector.Bounds
                Return New Rectangle(parentView.LogicalPointToScreen(bounds.Location), parentView.LogicalSizeToClient(bounds.Size))
            End Get
        End Property

        Public Overrides Property Name As String
            Get
                Return Me.connector.GetType.Name
            End Get
            Set(ByVal value As String)
            End Set
        End Property

        Public Overrides ReadOnly Property Parent As AccessibleObject
            Get
                Return Me.connector.ParentDesigner.AccessibilityObject
            End Get
        End Property

        Public Overrides ReadOnly Property Role As AccessibleRole
            Get
                Return AccessibleRole.Diagram
            End Get
        End Property


        ' Fields
        Private connector As Connector
    End Class
End Namespace

